<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { postLogin } from '@/api/login'
import { sustain } from '@/api/basis'
export default {
  name: 'app',
  data() {
    return {
      timer: null, //定时器名称
    }
  },
  created() {
    this.setTime();
    // this.connectWebSocket();
  },
  mounted() { },
  beforeDestroy() {
    clearInterval(this.timer);// 清除定时器
    this.timer = null;
    postLogin('POST',)
  },

  methods: {
    //每隔15分钟运行一次,为了保持token更新
    async setTime() {
      this.timer = await setInterval(() => {
        sustain().then(res => {
          // console.log(res);
        })
      }, 900000)
    },
  },

}
</script>

<style lang="scss" scoped>
@import "~@/assets/style/public-class.scss";

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
}

</style>
